package com.ajk.server.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ajk.server.controller.access.ArgIndexForPrintLog;
import com.ajk.server.model.Knowledge;
import com.ajk.server.model.request.KnowledgeReq;
import com.ajk.server.model.response.KnowledgeRes;
import com.ajk.server.model.response.ResultList;
import com.ajk.server.service.KnowledgeService;

@Controller
@RequestMapping("/knowledge")
public class KnowledgeController {

	@Autowired
	private KnowledgeService knowledgeService;

	/**
	 * 文章列表
	 * @param knowledge
	 * @return
	 */
	@ArgIndexForPrintLog(indexes={0})
	@ResponseBody
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public ResultList<KnowledgeRes> list(KnowledgeReq knowledge){
		List<KnowledgeRes> list = knowledgeService.list(knowledge,knowledge.getStart(),knowledge.getLimit());
		return new ResultList<>(list);
	}
	
	
	/**
	 * 文章列表
	 * @param knowledge
	 * @return
	 */
	@RequestMapping(value = "/detail", method = RequestMethod.GET)
	public String detail(Knowledge knowledge,Model model){
		KnowledgeRes  knowledgeRes = knowledgeService.detail(knowledge);
		model.addAttribute("knowledge", knowledgeRes);
		return "knowledge/detail";
	}
	
	/**
	 * 文章列表
	 * @param knowledge
	 * @return
	 */
	@RequestMapping(value = "/about_us", method = RequestMethod.GET)
	public String aboutUs(Knowledge knowledge,Model model){
		
		return "knowledge/about_us";
	}
	

}
